/* 
 * File:   RepositorioPollerTest.cpp
 * Author: gabilan
 *
 * Created on 24-may-2013, 19:21:37
 */

#include <stdlib.h>
#include <iostream>
#include <unistd.h>
#include "client_RepositorioPoller.h"
#include "RepositorioPollerManejadorEvetoDummy.h"

/*
 * Simple C++ Test Suite
 */
using namespace std;

void testDirInexistente() {
    std::cout << "RepositorioPollerTest DIR INEXISTENTE" << std::endl;
    
    Repositorio repositorio ("/home/aaa");
    RepositorioPollerManejadorEvetoDummy repositorioPollerManejadorEvetoDummy;
    
    RepositorioPoller poller (&repositorio, 1000 /*seg*/);
    poller.setRepositorioPollerManejadorEvento (reinterpret_cast <IRepositorioPollerManejadorEvento*> (&repositorioPollerManejadorEvetoDummy));

    try
    {
        poller.Iniciar();
        usleep (2000000);
    }
    catch (Excepcion &ex)
    {
        cout << endl << ex.what() << endl;
    }

    poller.Finalizar();
}

void testDirExistente() {
    std::cout << "RepositorioPollerTest test DIR EXISTENTE" << std::endl;
    
    Repositorio repositorio ("/home/gabilan/Escritorio/TPAUX/");
    RepositorioPollerManejadorEvetoDummy repositorioPollerManejadorEvetoDummy;
    
    RepositorioPoller poller (&repositorio, 200000 /*seg*/);
    poller.setRepositorioPollerManejadorEvento (reinterpret_cast <IRepositorioPollerManejadorEvento*> (&repositorioPollerManejadorEvetoDummy));

    try
    {
        poller.Iniciar();
        usleep (12000000);
    }
    catch (Excepcion &ex)
    {
        cout << endl << ex.what() << endl;
    }

    poller.Finalizar();
}

int main(int argc, char** argv) {
    std::cout << "%SUITE_STARTING% RepositorioPollerTest" << std::endl;
    std::cout << "%SUITE_STARTED%" << std::endl;

    std::cout << "%TEST_STARTED% test1 (RepositorioPollerTest)" << std::endl;
    testDirInexistente();
    std::cout << "%TEST_FINISHED% time=0 test1 (RepositorioPollerTest)" << std::endl;
    
    std::cout << "%TEST_STARTED% test1 (RepositorioPollerTest)" << std::endl;
    testDirExistente();
    std::cout << "%TEST_FINISHED% time=0 test1 (RepositorioPollerTest)" << std::endl;

    std::cout << "%SUITE_FINISHED% time=0" << std::endl;

    return (EXIT_SUCCESS);
}
